import java.util.Stack;

public class MyQueueUesStack {
  Stack<Integer> sta1;
  Stack<Integer> sta2;

        public MyQueueUesStack() {
                sta1 = new Stack<>();
                sta2 = new Stack<>();
        }

        public void push(int x) {
                sta1.push(x);
        }

        public int pop() {
                if(sta2.isEmpty()){
                        int size = sta1.size();
                        for (int i = 0; i < size; i++) {
                                sta2.push(sta1.pop());
                        }
                        return sta2.pop();
                }else return sta2.pop();
        }

        public int peek() {
                if(sta2.isEmpty()){
                        int size = sta1.size();
                        for (int i = 0; i < size; i++) {
                                sta2.push(sta1.pop());
                        }
                        return sta2.peek();
                }else return sta2.peek();
        }


        public boolean empty() {
                return sta1.isEmpty() && sta2.isEmpty();
        }

}
